package servlet.admin;

import entity.Pet;
import service.Impl.PetServiceImpl;
import service.PetService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/admin/PetList")
public class PetListServlet extends HttpServlet {
    private PetService petService = new PetServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("UTF-8");
        List<Pet> petList = petService.findAll();
        req.setAttribute("petList", petList);
        req.getRequestDispatcher("/admin/pet.jsp").forward(req, resp);
    }
}
